package com.anli.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/10  11:07
 * 描述:
 */
@RestController
public class TokenController {

    @Autowired
    private RedisTemplate redisTemplate;

    @RequestMapping("getToken")
    public String getToken(){

        String string = UUID.randomUUID().toString();

        redisTemplate.opsForValue().set(string,0);
        redisTemplate.expire(string,3600*24,TimeUnit.SECONDS);

        return string;
    }

}
